cc.Class({
    extends: cc.Component,

    properties: {
        d1 : cc.Button,
        d2 : cc.Button,
        d3 : cc.Button,
        d4 : cc.Button,
        d5 : cc.Button,
        d6 : cc.Button,
        d7 : cc.Button,
        d8 : cc.Button,
        d9 : cc.Button, 
        score : cc.Float,
        scorelabel:cc.Label,    
    },

    // use this for initialization
    onLoad: function () {
        this.score=0;
        //this.d1.node.color=cc.Color.BLUE;
    },

    update:function(){
        this.scorelabel.string='分数：'+this.score;
    },

    onD1Clicked: function(event){   
        if(this.d1.node.color.equals(cc.Color.WHITE)){
            this.d1.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d1.node.color.equals(cc.Color.BLUE)){
            this.d1.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD2Clicked: function(event){   
        if(this.d2.node.color.equals(cc.Color.WHITE)){
            this.d2.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d2.node.color.equals(cc.Color.BLUE)){
            this.d2.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD3Clicked: function(event){   
        if(this.d3.node.color.equals(cc.Color.WHITE)){
            this.d3.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d3.node.color.equals(cc.Color.BLUE)){
            this.d3.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD4Clicked: function(event){   
        if(this.d4.node.color.equals(cc.Color.WHITE)){
            this.d4.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d4.node.color.equals(cc.Color.BLUE)){
            this.d4.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD5Clicked: function(event){   
        if(this.d5.node.color.equals(cc.Color.WHITE)){
            this.d5.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d5.node.color.equals(cc.Color.BLUE)){
            this.d5.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD6Clicked: function(event){   
        if(this.d6.node.color.equals(cc.Color.WHITE)){
            this.d6.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d6.node.color.equals(cc.Color.BLUE)){
            this.d6.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD7Clicked: function(event){   
        if(this.d7.node.color.equals(cc.Color.WHITE)){
            this.d7.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d7.node.color.equals(cc.Color.BLUE)){
            this.d7.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD8Clicked: function(event){   
        if(this.d8.node.color.equals(cc.Color.WHITE)){
            this.d8.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d8.node.color.equals(cc.Color.BLUE)){
            this.d8.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },

    onD9Clicked: function(event){   
        if(this.d9.node.color.equals(cc.Color.WHITE)){
            this.d9.node.color=cc.Color.RED;
            this.score--;
        }
        else if(this.d9.node.color.equals(cc.Color.BLUE)){
            this.d9.node.color=cc.Color.WHITE;
            this.score++;          
        }
    },
});
